From 4586ca34b523b9cd2f14db68226d76e31af6f141 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 11 Jul 2018 20:35:37 +0200 Subject: [PATCH] babl: simplify the singleton logic in babl_format_with_space --- babl/babl-format.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/babl/babl-format.c b/babl/babl-format.c index bc5ef6b..3af5adc 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -148,7 +148,7 @@ format_new_from_format_with_space (const Babl *format, const Babl *space) space, format->format.component, format->format.sampling, (void*)format->format.type); - + babl_db_insert (db, (void*)ret); return ret; } @@ -713,8 +713,6 @@ BABL_CLASS_IMPLEMENT (format) const Babl * babl_format_with_space (const char *name, const Babl *space) { - const Babl *ret = NULL; - if (!space) space = babl_space ("sRGB"); if (space->class_type == BABL_FORMAT) { @@ -731,21 +729,7 @@ babl_format_with_space (const char *name, const Babl *space) if (space == babl_space("sRGB")) return babl_format (name); - { - char *new_name = babl_malloc (strlen (name) + - strlen (babl_get_name ((Babl*)space)) + 2); - sprintf (new_name, "%s-%s", name, babl_get_name ((Babl*)space)); - - ret = babl_db_exist_by_name (db, new_name); - - babl_free (new_name); - if (ret) - return ret; - - ret = format_new_from_format_with_space (babl_format (name), space); - babl_db_insert (db, (void*)ret); - } - return ret; + return format_new_from_format_with_space (babl_format (name), space); } int -- 2.30.2